<?php
/**
 * Creates a 'now loading' message for ajax
 * @author Von Held
 * @license MIT
 * @version 0.1
 * @since 2008/05/14
 */
class AjaxloaderinfoHelper extends AppHelper
{
    var $helpers = array('Html','Javascript','Head', 'Form', 'Ajax');

    /**
     * Creates the 'loading' message for an especified element id
     * @param string $id Field Id wich is refered
     * @param string $message Message to show
     * @param string $image Allows change the image 
     * @return string
     */
    function load_info($id, $style=array(), $message="Aguarde...", $image="ajax-loader.gif")
    {
        ob_start();
        $stream ="";
        foreach ($style as $atributo=>$value) {
        	$stream.="{$atributo}:{$value};";
        }
        echo "<div id='{$id}' class='load' style='{$stream}'>";
        echo $this->Html->image($image, array('alt'=>$message, 'align'=>"absmiddle"));
        echo "&nbsp;&nbsp;<span style='vertical-align:middle;'>{$message}</span>";
    	echo "</div>";    
        return ob_get_clean();
    }
    
    function load_info_span($id, $style=array(), $message="Aguarde...", $image="ajax-loader.gif")
    {
        ob_start();
        $stream ="";
        foreach ($style as $atributo=>$value) {
        	$stream.="{$atributo}:{$value};";
        }
        echo "<span id='{$id}' class='load' style='{$stream}'>";
        echo $this->Html->image($image, array('alt'=>$message, 'align'=>"absmiddle"));
        if(!empty($message))
        	echo "&nbsp;&nbsp;{$message}";
    	echo "</span>";    
        return ob_get_clean();
    }
}
?>
